<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ include file="/common/include.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title>tueye广告添加广告内容-tueye广告管理-tueye专业的图片欣赏交流社区</title>
	　
		<script type="text/javascript" src="<%=request.getContextPath() %>/script/jquery.js"></script>
			<script type="text/javascript"	src="<%=request.getContextPath() %>/script/ajaxfileupload.js"></script>
		<script type="text/javascript">
		 function changesite(obj){
		  	if(obj == 1 ){
		  		$('#adsitedes_local').show();
		  		$('#adsitedes').hide();
		  	}else{
		  	 $('#adsitedes').show();
		  	 $('#adsitedes_local').hide();
		  	}
		 }
		</script>
	</head>

	<body>
		<form method="post"　enctype="multipart/form-data">
		<input name="adsite_id" id="adsite_id" type="hidden" value="<%=request.getParameter("adsite_id")%>" />
		<input name="type" id="type" type="hidden" value="" />
		<input name="id" id="id" type="hidden" value="${adinfo.id}" />
		<input name="picture_site_type" id="picture_site_type" type="hidden" value="${adinfo.picture_site_type}" />
		<input name="adinfo_point_num" id="adinfo_point_num" type="hidden" value="${adinfo.adinfo_point_num}" />
		<input name="adpicture_site" id="adpicture_site" type="hidden" value="${adinfo.adpicture_site}" />
			<table>
				<tr>
					<td>
						<label for="projects">
							    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;广告标题：
						</label>
						<input name="adinfo_title" id="adinfo_title" type="text" value="${adinfo.adinfo_title}" size=24 />
					</td>
				</tr>
				<tr>
					<td>
						<label for="projects">
							    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;标题显示长度：
						</label>
						<input name="adinfo_title_length" id="adinfo_title_length" type="text" value="${adinfo.adinfo_title_length }" size=24 />
					</td>
				</tr>
				<tr>
					<td>
						<label for="projects">
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;广告描述：
						</label>
						<input name="adinfo_description" id="adinfo_description" type="text"  value="${adinfo.adinfo_description}" size=24 />
					</td>
				</tr>
				<tr>
					<td>
						<label for="projects">
							    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;描述显示长度：
						</label>
						<input name="adinfo_description_length" id="adinfo_description_length" type="text" value="${adinfo.adinfo_description_length }" size=24 />
					</td>
				</tr>
				<tr>
					<td>
						<label for="projects">
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;广告等级：
						</label>
						　
						<select name="adinfo_level" id="adinfo_level">
						 <option value="1">1</option>
						 <option value="2">2</option>
						 <option value="3">3</option>
						 <option value="4">4</option>
						 <option value="5">5</option>
						 <option value="6">6</option>
						 <option value="7">7</option>
						 <option value="8">8</option>
						 <option value="9">9</option>
						 <option value="10">10</option>
						 <option value="11">11</option>
						 <option value="12">12</option>
						 <option value="13">13</option>
						 <option value="14">14</option>
						 <option value="15">15</option>
						 <option value="16">16</option>
						 <option value="17">17</option>
						 <option value="18">18</option>
						 <option value="19">19</option>
						 <option value="20">20</option> 
						</select>
					</td>
				</tr>
				<tr>
					<td>
						<label for="projects">
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;广告链接：
						</label>
						<input name="adinfo_address" id="adinfo_address" type="text"  value="${adinfo.adinfo_address}" size=24 />
					</td>
				</tr>
				
				<tr>
					<td>
					    
                        <img alt="" src="<%=request.getContextPath() %>/pages/topics/aduploadimg/${adinfo.adpicture_site}"/>
					    <br>
						<label for="projects">
							本地图片上传：
						</label>
						<input name="adpicture_site_local" id="adpicture_site_local" type="file"  size=24 />
						
					</td>
				</tr>
				
				<tr>
					<td align="center">
						<input type="button" value="保存" onclick="savePageName()" />
						&nbsp;&nbsp;
					</td>
				</tr>


			</table>
		</form>
		<script>
// 验证,然后 保存界面
function savePageName()
{
var adsite_id=$("#adsite_id").val();
var adinfo_title=$("#adinfo_title").val();
var adinfo_level=$("#adinfo_level").val();
var adinfo_description = $('#adinfo_description').val();
var adinfo_address=$("#adinfo_address").val();
 
 var adinfo_title_length = $("#adinfo_title_length").val;
var adinfo_description_length = $("#adinfo_description_length").val;

var adpicture_site=$("#adpicture_site").val();
var id = $('#id').val();
var type = $('#type').val();

  var picture_site_type = $('input[@name=picture_site_type][@checked]').val();
  
  
if(adinfo_title==""||adinfo_title==null ) 
{
alert("广告标题名称不能为空!")
$("#adinfo_title").focus();
  return;
}

if(adinfo_level==""||adinfo_level==null ) 
{
alert("广告等级不能为空!")
$("#adinfo_level").focus();
  return;
} 
if(picture_site_type != 1 && picture_site_type != 2){
 picture_site_type = 3;
}
var sendData="&adinfo_title="+ encodeURIComponent(adinfo_title)+"&adinfo_level="+encodeURIComponent(adinfo_level)
+"&adinfo_description="+encodeURIComponent(adinfo_description)+"&adinfo_address="+encodeURIComponent(adinfo_address)
+"&picture_site_type="+encodeURIComponent(picture_site_type)+"&adpicture_site="+encodeURIComponent(adpicture_site)
+"&adsite_id="+encodeURIComponent(adsite_id)
+"&date="+new Date()+"&id="+id+"&type="+type+"&adinfo_title_length="+encodeURIComponent(adinfo_title_length)
+"&adinfo_description_length="+encodeURIComponent(adinfo_description_length); 
 
				$.ajaxFileUpload(
                   {
		                url:'<%=request.getContextPath()%>/adinfo.do?action=update',            //需要链接到服务器地址
		                secureuri:false,
		                fileElementId:'adpicture_site_local',                        //文件选择框的id属性
		                dataType: 'json',   
		                data: sendData ,                                   //服务器返回的格式，可以是json
		                success: function (data, status)            //相当于java中try语句块的用法
		                {      
		                 	 window.location.reload();
		                },
		                error: function (data, status, e)            //相当于java中catch语句块的用法
		                {
		                   　window.location.reload();
		                }
            }   );    
    	
         }   
 
    
			

</script>
	</body>
</html>
